<template>
  <button class="zt-button" disabled :class="[type ? 'zt-button-' + type : '', block ? 'btn-block' : '']" @click="handleClick">
    <span v-if="$slots.default"><slot></slot></span>
  </button>
</template>

<script>
  export default {
    name: 'Button',
    props: {
      type: String,
      block: {
        type: Boolean,
        default: false
      },
      disabled: {
        type: Boolean,
        default: false
      }
    },
    methods: {
      handleClick(e) {
        this.$emit('click', e)
      }
    }
  }
</script>

<style lang="less" scoped>
  .zt-button {
    display: inline-block;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    background: #fff;
    border: 1px solid #dcdfe6;
    color: #606266;
    -webkit-appearance: none;
    text-align: center;
    box-sizing: border-box;
    outline: none;
    margin: 0;
    transition: 0.1s;
    font-weight: 500;
    -moz-user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    padding: 12px 20px;
    font-size: 14px;
    border-radius: 4px;
  }

  .zt-button:focus,
  .zt-button:hover {
    color: #409eff;
    border-color: #c6e2ff;
    background-color: #ecf5ff;
  }

  .zt-button:active {
    color: #3a8ee6;
    border-color: #3a8ee6;
    outline: none;
  }
  .zt-button-primary {
    color: #fff;
    background-color: #409eff;
    border-color: #409eff;
  }

  .zt-button-primary:focus,
  .zt-button--primary:hover {
    background: #66b1ff;
    border-color: #66b1ff;
    color: #fff;
  }
  .zt-button-success {
    color: #fff;
    background-color: rgb(103, 194, 58);
    border-color: rgb(103, 194, 58);
  }

  .zt-button-success:focus,
  .zt-button--success:hover {
    background: rgb(103, 194, 58);
    border-color: rgb(103, 194, 58);
    color: #fff;
  }
  .zt-button-danger {
    color: #fff;
    background-color: rgb(245, 108, 108);
    border-color: rgb(245, 108, 108);
  }

  .zt-button-danger:focus,
  .zt-button--danger:hover {
    background: rgb(245, 108, 108);
    border-color: rgb(245, 108, 108);
    color: #fff;
  }
  .btn-block {
    width: 100%;
    margin: 0 !important;
  }
  .zt-button {
    margin-left: 10px;
  }
</style>
